package com.six.work.controller;

import com.six.work.entity.Announcement;
import com.six.work.entity.Applicant;
import com.six.work.entity.Swords;
import com.six.work.services.SwordsServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("swords")
public class SwordsController {
    @Autowired
    private SwordsServices swordsServices;

    @GetMapping("/list")
    public List<Swords> findAllSwords(){
        List<Swords> list = swordsServices.findAllSwords();
        return list;
    }

    @GetMapping("/del")
    public Integer deleteByID(@RequestParam("word_id") Integer word_id){
        return swordsServices.DelSwordsByID(word_id);
    }

    @PostMapping("/add")
    public Integer InsertSwords(@RequestBody Swords swords){

        return swordsServices.insertSwords(swords);
    }


    @GetMapping("/update")
    public Swords getUpdatePage(@RequestParam("word_id") Integer word_id){

        return swordsServices.SelectSwordsByID(word_id);
    }

    @PostMapping("/update")
    public Integer UpdateSwords(@RequestBody Swords swords) {

        return swordsServices.updateSwords(swords);
    }
}
